/*
 * @lc app=leetcode.cn id=455 lang=typescript
 *
 * [455] 分发饼干
 */

// @lc code=start
function findContentChildren(g: number[], s: number[]): number {
    g.sort((a, b) => a - b);
    s.sort((a, b) => a - b);
    let i = 0;
    let j = 0;
    let count = 0;
    while (g[i] && s[j]) {
        if (g[i] <= s[j]) {
            count++;
            i++;
            j++;
        }
        if (g[i] > s[j]) {
            j++;
        }
    }
    return count;
}
// @lc code=end
